package com.vodafone.mapreduce.dto.function;

import java.io.Serializable;

import org.corf.payload.Payload;
import org.corf.payload.PayloadType;

import com.vodafone.mapreduce.MapReduce;

/**
 * Input for the map function. This map function will transform the input (k, v) into 0..n (l, w).
 * 
 * @param <K>
 * @param <V>
 */
public class MapInput<K, V> extends Payload implements Serializable {

    // -------------------------------------------------------------------------------------------------------------------------------------
    // Class constants.
    // -------------------------------------------------------------------------------------------------------------------------------------

    private static final long serialVersionUID = MapReduce.SERIAL_VERSION_UID;

    // -------------------------------------------------------------------------------------------------------------------------------------
    // Instance attributes.
    // -------------------------------------------------------------------------------------------------------------------------------------

    private K k;
    private V v;

    // -------------------------------------------------------------------------------------------------------------------------------------
    // Instance constructors.
    // -------------------------------------------------------------------------------------------------------------------------------------

    public MapInput() {
        super(PayloadType.EVENT, "Yo, mama!");
    }

    // -------------------------------------------------------------------------------------------------------------------------------------
    // Instance methods.
    // -------------------------------------------------------------------------------------------------------------------------------------

    public K getKey() {
        return k;
    }

    public V getValue() {
        return v;
    }

    public void setKey(K k) {
        this.k = k;
    }

    public void setValue(V v) {
        this.v = v;
    }

    public MapInput<K, V> withKey(K k) {
        setKey(k);
        return this;
    }

    public MapInput<K, V> withValue(V v) {
        setValue(v);
        return this;
    }

    public String toString() {
        return "(" + k + ", " + v + ")";
    }

    // -------------------------------------------------------------------------------------------------------------------------------------

}
